attribute vec4 position; 
attribute vec4 color; 
attribute vec4 normal;

varying vec3  pReflectDir;			//	reflection direction mapped to a texture coordinate in cube texture

uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform mat4 normalMatrix;

uniform mat4 adjustMatrix;			//	if the scene has rotated,use this matrix to adjust reflection direction

void main()
{
	vec4 eyePos = modelViewMatrix * position;
    vec3 eyeNormal = (normalMatrix * normal).xyz;
	
	vec3 eyeDir = eyePos.xyz;	//	eye to vertex
    pReflectDir = (adjustMatrix * vec4(reflect(eyeDir, eyeNormal), 0.0)).xyz;

	gl_Position = projectionMatrix * modelViewMatrix * position;
}